29_Simple Append text to a file.py.py


Sign up Free. Don't forget to check out our challenges, lessons, solve and learn series and more ...


Code Snippet

def file_read(fname):  
        from itertools import islice  
        with open(fname, "w") as myfile:  
                myfile.write("Python Exercises\n")  
                myfile.write("Java Exercises")  
        txt = open(fname)  
        print(txt.read())  
file_read('abc.txt')
                    

Try it yourself